package com.huike.business.service.impl;


import com.huike.business.domain.TbBusinessTrackRecord;
import com.huike.business.mapper.TbBusinessTrackRecordMapper;
import com.huike.business.service.ITbBusinessTrackRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TbBusinessTrackRecordServiceImpl implements ITbBusinessTrackRecordService {

    @Autowired
    private TbBusinessTrackRecordMapper tbBusinessTrackRecordMapper;
    /**
     * 商机跟进记录列表
     *
     * @param businessId
     * @return
     */
    @Override
    public List<TbBusinessTrackRecord> getTbBusinessTrackRecordByBusinessId(Long businessId) {
        //获取跟进记录
        List<TbBusinessTrackRecord> tbBusinessTrackRecordList = tbBusinessTrackRecordMapper.getTbBusinessTrackRecordByBusinessId(businessId);
        for (TbBusinessTrackRecord tbBusinessTrackRecord : tbBusinessTrackRecordList) {
            List<String> keys = tbBusinessTrackRecord.getKeys();
            String keyItems = tbBusinessTrackRecord.getKeyItems();
           if (keyItems!=null){
               String[] keyItemsStr = keyItems.split(",");
               for (String s : keyItemsStr) {
                   String keyItem = tbBusinessTrackRecordMapper.getKeyByKetItem(s);
                   keys.add(keyItem);
               }
               tbBusinessTrackRecord.setKeys(keys);
           }
        }
        return tbBusinessTrackRecordList;
    }

}
